#pragma once

#include <d3d9.h>
#include <d3dx9.h>

#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

class cCamera_AL
{
private:
	D3DXMATRIX	m_mProjectionMatrix;
	D3DXMATRIX	m_mViewMatrix;
public:
	cCamera_AL();
	~cCamera_AL();

	D3DXMATRIX GetProjectionMatrix() { return m_mProjectionMatrix; }
	void SetProjectionMatrix(D3DXMATRIX *_mMatrix) { memcpy(&this->m_mProjectionMatrix, _mMatrix, sizeof(D3DXMATRIX)); }
		
	void BuildPerspective(float _fFieldOfView, float _fAspect, float _fZNear, float _fZFar);
	void SetViewMatrix(D3DXMATRIX *_mMatrix) { memcpy(&this->m_mViewMatrix, _mMatrix, sizeof(D3DXMATRIX)); }

	D3DXMATRIX GetViewMatrix(bool _bTranslate);
	void NormalizeViewMatrix();

	D3DXVECTOR3 GetViewXAxis(void)
	{	return D3DXVECTOR3(m_mViewMatrix._11,
							m_mViewMatrix._12,
							m_mViewMatrix._13); }
	void SetViewXAxis(D3DXVECTOR3 _vPosition);
	void SetViewXAxis(float _fX,float _fY,float _fZ);

	D3DXVECTOR3 GetViewYAxis(void)
	{	return D3DXVECTOR3(m_mViewMatrix._21,
							m_mViewMatrix._22,
							m_mViewMatrix._23);	}
	void SetViewYAxis(D3DXVECTOR3 _vPosition);
	void SetViewYAxis(float _fX,float _fY,float _fZ);

	D3DXVECTOR3 GetViewZAxis(void)
	{	return D3DXVECTOR3(m_mViewMatrix._31,
							m_mViewMatrix._32,
							m_mViewMatrix._33);	}
	void SetViewZAxis(D3DXVECTOR3 _vPosition);
	void SetViewZAxis(float _fX,float _fY,float _fZ);

	D3DXVECTOR3 GetViewPosition(void)
	{	return D3DXVECTOR3(m_mViewMatrix._41,
						   m_mViewMatrix._42,
						   m_mViewMatrix._43); }
	void SetViewPosition(D3DXVECTOR3 _vPosition);
	void SetViewPosition(float _fX, float _fY, float _fZ);

	/*=================================================================
	Local Transform Functions
	//===============================================================*/
	void ViewRotateLocalX(float _fAngle);
	void ViewRotateLocalY(float _fAngle);
	void ViewRotateLocalZ(float _fAngle);

	void ViewTranslateLocal(D3DXVECTOR3 _vAxis, bool _bFPS = false);
	void ViewTranslateLocalX(float _fScale, bool _bFPS = false);
	void ViewTranslateLocalY(float _fScale, bool _bFPS = false);
	void ViewTranslateLocalZ(float _fScale, bool _bFPS = false);

	/*=================================================================
	Global Transform Functions
	//===============================================================*/
	void ViewRotateGlobalX(float _fAngle);
	void ViewRotateGlobalY(float _fAngle);
	void ViewRotateGlobalZ(float _fAngle);

	void ViewTranslateGlobal(D3DXVECTOR3 _vAxis)
	{
		this->m_mViewMatrix._41 += _vAxis.x;
		this->m_mViewMatrix._42 += _vAxis.y;
		this->m_mViewMatrix._43 += _vAxis.z;
	}
	void ViewTranslateGlobalX(float _fScale) { this->m_mViewMatrix._41 += _fScale; }
	void ViewTranslateGlobalY(float _fScale) { this->m_mViewMatrix._42 += _fScale; }
	void ViewTranslateGlobalZ(float _fScale) { this->m_mViewMatrix._43 += _fScale; }
};

